﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using DTO;
using System.Data;
namespace BUS
{
    public class HanhKhachBUS
    {
        HanhKhachDAO obj = new HanhKhachDAO();
        public HanhKhachDTO layCt(string i)
        {
            
            return obj.GetChitiet(i);
        }
        #region Đinh Vũ Phương
        public int Them(HanhKhachDTO hk)
        {
            string sql = string.Format("Insert into HanhKhach(MaHanhKhach,TenHanhKhach,CMND,DienThoai) values('{0}',N'{1}','{2}','{3}')",hk.MaHK,hk.TenHK,hk.CMND1,hk.DienThoai);
            return obj.CapNhat(hk, sql);
        }
        public int Sua(HanhKhachDTO hk)
        {
            string sql = " Update HanhKhach ";
            sql+="Set TenHanhKhach=N'" +hk.TenHK  + "', ";
            sql += "CMND='" + hk.CMND1 + "', ";
            sql += "DienThoai='" + hk.DienThoai + "' ";
            sql += "Where MaHanhKhach='" + hk.MaHK + "'";
            return obj.CapNhat(hk, sql);
        }
        public int Xoa(HanhKhachDTO hk)
        {
            string sql = "Delete from HanhKhach where MaHanhKhach=N'" + hk.MaHK+ "'";
            return obj.CapNhat(hk, sql);
        }
        public List<HanhKhachDTO> getALL()
        {
            return obj.getAll();
        }
        public bool KTMaKH(string maKH)
        {
            return obj.KTMaHK(maKH);
        }
        #endregion
    }
}
